<template>
  <div class="allotModal">
    <div>
      <Input style="width: 300px; marginRight: 10px" maxlength="32"
             :placeholder="`${$t('common.inputInfo')}`" v-model="name" />
      <Button type="primary">{{$t('common.Query')}}</Button>
    </div>
    <div class="list">
      <div v-for="(item, index) in list" :key="index" :class="{'active': item.selected}" class="listItem" @click="selectPerson(item)">
        <div class="jobNumber">
          <label>工号：</label>
          <span>{{item.jobNumber}}</span>
        </div>
        <div class="name">
          <label>姓名：</label>
          <span>{{item.name}}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'allotModal',
  props: ['list'],
  data() {
    return {
      name: '',
    }
  },
  methods: {
    selectPerson(item) {
      if (item.selected) {
        item.selected = false
      } else {
        item.selected = true
      }
    }
  }
}
</script>

<style lang="scss">
.allotModal {
  .list {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    .listItem {
      flex: 0 0 18%;
      margin: 10px 8px;
      height: 80px;
      border: 1px solid #DDDDDD;
      border-radius: 5px;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      align-items: center;
      .jobNumber {
        margin-top: 15px;
      }
      .name {
        margin-bottom: 15px;
      }
    }
    .active {
      border: 1px solid #187BDB;
    }
  }
}
</style>
